package com.sutong.platform.utils;

import cn.hutool.core.util.StrUtil;

public class DecimalToBase64Converter {

    // 64进制字符集
    private static final String BASE64_CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";

    // 十进制转64进制
    public static String decimalToBase64(long decimal) {
        StringBuilder base64 = new StringBuilder();
        while (decimal > 0) {
            int remainder = (int) (decimal % 64);
            base64.append(BASE64_CHARSET.charAt(remainder));
            decimal /= 64;
        }
        return StrUtil.reverse(base64.toString());
    }
}
